package com.llkj.qingnianguoxue.circle;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.widget.EditText;

import com.jm.chat.pickerimage.utils.StringUtil;
import com.llkj.qingnianguoxue.R;
import com.llkj.qingnianguoxue.base.BaseActivity;
import com.llkj.qingnianguoxue.http.HttpMethod;
import com.llkj.qingnianguoxue.util.StringUtils;
import com.llkj.qingnianguoxue.util.ToastUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

public class AppyVerificationActivity extends BaseActivity {

    @BindView(R.id.etChatGreet)
    protected EditText etChatGreet;
    private String mFriendId;//好友id

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_appy_verification);
        setTitle("好友验证", true, TITLE_TYPE_IMG, R.drawable.icon_back, true,TITLE_TYPE_TEXT, "发送");
        initStatusbar(TSATUSBAR_TYPE_BLACK_TEXT,rlTitle,R.color.gray_bar);
        tvRight.setTextColor(ContextCompat.getColor(this, R.color.blue3989ff));
        ButterKnife.bind(this);
        Bundle bundle = getIntent().getExtras();
        if(bundle!=null){
            mFriendId = bundle.getString("uid");
        }

    }

    @Override
    protected void rightDoWhat() {
        super.rightDoWhat();
        String chatGreet = etChatGreet.getText().toString();
        if(StringUtils.isEmpty(chatGreet)){
            ToastUtil.makeLongText(this,"请输入验证内容");
            return;
        }

        if(!StringUtils.isEmpty(mFriendId)){
            loadWaitDialog();
            HttpMethod.addFriend(this,this,mFriendId,chatGreet);
        }
    }

    @Override
    protected void dialogRightBtn() {
        super.dialogRightBtn();
        setResult(RESULT_OK,new Intent());
        finish();
    }

    @Override
    protected void onhttpSuccess(String data, int method) {
        super.onhttpSuccess(data, method);
        if(method == HttpMethod.HTTP_CIRCLE_ADD_FRIEND) {//6.6发起好友申请
            dialogPrompt(getString(R.string.wait_friend_agree),null,"确定").show();
        }
    }
}
